﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;

namespace A2DFramework.ValidationService.RuleValidators
{
    public class RuleRangeAttribute:RuleValidationAttribute
    {
        private RangeAttribute checker;

        public RuleRangeAttribute(string rule, double minimum, double maximum)
            : base(rule)
        {
            checker = new RangeAttribute(minimum, maximum);
        }
        public RuleRangeAttribute(string rule, int minimum, int maximum)
            : base(rule)
        {
            checker = new RangeAttribute(minimum, maximum);
        }
        public RuleRangeAttribute(string rule, Type type, string minimum, string maximum)
            : base(rule)
        {
            checker = new RangeAttribute(type, minimum, maximum);
        }

        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            return checker.GetValidationResult(value, validationContext);
        }
    }
}
